package meihua.stopcarapp.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import meihua.stopcarapp.utils.ScreenUtils;

/**
 * Created by Administrator on 2017/5/8.
 */

public abstract class SelectPicDialog extends Dialog {

    private WindowManager.LayoutParams params;
    public SelectPicDialog(@NonNull Context context) {
        super(context);
        init(context);
    }

    public SelectPicDialog(@NonNull Context context, @StyleRes int themeResId) {
        super(context, themeResId);
        init(context);
    }

    private void init(Context context){
        View view=View.inflate(context,getLayoutId(),null);
        setContentView(view);
        Window window = getWindow();
        params = window.getAttributes();
        params.width = ScreenUtils.getScreenWidth(context);
        params.gravity = Gravity.BOTTOM;
        window.setAttributes(params);
        initDialog(view);
    }

    public abstract int getLayoutId();

    public abstract void initDialog(View view);
}
